﻿namespace DesignModeConsole.ClassRelation;

/// <summary>
/// 飞
/// </summary>
public interface IFly
{
    void Flay();
}

/// <summary>
/// 大雁
/// 大雁和非是实现关系
/// </summary>
public class WildGoose : IFly
{
    public void Flay()
    {
        Console.WriteLine("大雁飞");
    }

    public void LayEggs()
    {
        Console.WriteLine("下蛋");
    }
}

/// <summary>
/// 大雁群   和大雁类是聚合关系
/// </summary>
public class WildGooseGroup
{
    public List<WildGoose> WildGeeseList { get; set; }
}

/// <summary>
/// 水
/// </summary>
public class Water
{
}

/// <summary>
/// 氧气
/// </summary>
public class Oxygen
{
}

/// <summary>
/// 动物
/// 动物依赖水和氧气
/// </summary>
public abstract class Animal
{
    public Animal(Water water, Oxygen oxygen)
    {
    }

    /// <summary>
    /// 生命
    /// </summary>
    public bool Life { get; set; }
}

/// <summary>
/// 鸟
/// 鸟和翅膀是组合关系
/// 鸟和动物是继承关系也是泛化
/// </summary>
public class Bird : Animal
{
    public Bird(Water water, Oxygen oxygen) : base(water, oxygen)
    {
        this.Wing=new Wing();
    }

    /// <summary>
    /// 羽毛
    /// </summary>
    public Wing Wing { get; set; }
}

/// <summary>
/// 翅膀
/// </summary>
public class Wing
{
}

/// <summary>
/// 企鹅
/// 企鹅类和气候类属于关联关系
/// </summary>
public class Penguin : Bird
{
    public Penguin(Water water, Oxygen oxygen) : base(water, oxygen)
    {
    }

    /// <summary>
    /// 气候类
    /// </summary>
    public Climate Climate { get; set; }

    public void LayEggs()
    {
        Console.WriteLine("下蛋");
    }
}

/// <summary>
/// 气候类
/// </summary>
public class Climate
{
}